<?php
//
// +------------------------------------------------------------------------+
// | PHP Version 5                                                          |
// +------------------------------------------------------------------------+
// | Copyright (c) All rights reserved.                                     |
// +------------------------------------------------------------------------+
// | This source file is subject to version 3.00 of the PHP License,        |
// | that is available at http://www.php.net/license/3_0.txt.               |
// | If you did not receive a copy of the PHP license and are unable to     |
// | obtain it through the world-wide-web, please send a note to            |
// | license@php.net so we can mail you a copy immediately.                 |
// +------------------------------------------------------------------------+
// | Author:                                                                |
// +------------------------------------------------------------------------+
//
// $Id$
//


/**
 * @author       mk
 */
class ConnectionManager {
    
    /**
     * @var      array
     */
    protected static $db = array();
    
    /**
     * @param    string $name    
     * @return   BaseDriver
     */
    static public function getConn($name = "default") {
        if (!in_array($name, array_keys(self::$db))) {
            self::$db[$name] = self::loadDatasource(DATABASE_CONFIG::$$name);
        }
        return self::$db[$name];
    }
    
    /**
     * @param    array $conn    
     * @return   BaseDriver
     */
    static protected function loadDatasource($config) {
        $driver = $config['driver'];
        return new $driver($config);
    }
}

?>